package com.remoter.basic.context;

import java.io.Closeable;

import com.remoter.basic.bean.support.ConsumerModule;
import com.remoter.basic.bean.support.ProviderModule;
import com.remoter.basic.bean.support.RemoterRequest;
import com.remoter.basic.transport.IServer;
import com.remoter.basic.util.ServiceLoader.SPI;

/**
 * @author			koko
 * @date 			2017-08-08 13:14:56
 * @description 	上下文衔接
 */
@SPI
public interface IContext extends Closeable{
	
	public ProviderModule getProviderModule(RemoterRequest remoterRequest);
	
	public ConsumerModule getConsumerModule(RemoterRequest remoterRequest);
	
	
	public ProviderModule createProviderModule(String protocol);
	public IServer attachProvider(ProviderModule providerModule)throws Exception;
	public void detachProviderModule(ProviderModule providerModule)throws Exception;
	
	public ConsumerModule createConsumerModule(String protocol);
	public <T> T attachConsumer(Class<T> type,ConsumerModule consumerModule)throws Exception;
	public void detachConsumerModule(ConsumerModule consumerModule)throws Exception;
	
}